home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / util / misc / Change.lha / Change / source / Include / SDI_ASM_STD_protos.h < prev    next >
C/C++ Source or Header  |  1998-01-10  |  5KB  |  144 lines

  1. #ifndef SDI_ASM_STD_PROTOS_H
  2. #define SDI_ASM_STD_PROTOS_H
  3.  
  4. /* Includeheader
  5.  
  6.     Name:        SDI_ASM_STD_protos
  7.     Versionstring:    $VER: SDI_ASM_STD_protos.h 1.15 (27.07.97)
  8.     Author:        SDI
  9.     Distribution:    PD
  10.     Description:    my replacement for standard ANSI functions
  11.  
  12.  1.9   18.11.96 : converted text into english language, changed C++ comments
  13.      to C ones
  14.  1.10  29.11.96 : added printf
  15.  1.11  06.02.97 : added exit prototype
  16.  1.12  28.03.97 : added some additionally defines (AMIGA_TO_ANSI), added
  17.      vsprintf
  18.  1.13  31.05.97 : fixed SDI_isprintf
  19.  1.14  20.07.97 : changed UBYTE ** to STRPTR *
  20.  1.15  27.07.97 : fixed SDI_printf
  21. */
  22.  
  23. /* These are mainly the normal ANSI C functions, but with an ASM interface.
  24. You can replace them by their normal functions supplied with your compiler,
  25. but do not mix them up (one object file standard, the other one SDI).
  26.  
  27. differences:
  28.  toupper and tolower: chars (0x41 to 0x5A) and (0xC0 to 0xDE) are upper
  29.   chars (0x61 to 0x79) and (0xE0 to 0xFE) are lower (some more than in ANSI)
  30.  isprint: chars (0x20 to 0x7E) and (0xA0 to 0xFF) are printable
  31.  sprintf and printf: only support exec/RawDoFmt format strings
  32.   and some I do not remember.
  33.  strtoul and strtol: return NULL in errpos, when '\0'-Byte was last scanned
  34.   character. I do not know, if this is really correct for ANSI.
  35.  
  36.  all: return values may not match ANSI-C ones
  37.  
  38. printf: Use this function only for programs need to work under OS1.3. For
  39. OS2.0 (and up) programs should use dos.library/amiga.lib Printf function.
  40. */
  41.  
  42. #include <exec/types.h>
  43.  
  44. #ifdef __MAXON__
  45.   #define __asm
  46. #endif
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. BYTE __asm SDI_strnicmp(register __a0 STRPTR,    /* string 1            */
  53.             register __a1 STRPTR,    /* string 2            */
  54.             register __d1 ULONG);    /* highest testlength        */
  55. BYTE __asm SDI_strncmp(    register __a0 STRPTR,    /* string 1            */
  56.             register __a1 STRPTR,    /* string 2            */
  57.             register __d1 ULONG);    /* highest testlength        */
  58. UBYTE __asm SDI_tolower(register __d0 UBYTE);    /* character to convert        */
  59. UBYTE __asm SDI_toupper(register __d0 UBYTE);    /* character to convert        */
  60. ULONG __asm SDI_strlen( register __a0 STRPTR);    /* string            */
  61. ULONG __asm SDI_isprint(register __d0 UBYTE);    /* character to convert        */
  62. ULONG __asm SDI_isdigit(register __d0 UBYTE);    /* character to convert        */
  63. ULONG __asm SDI_isxdigit(register __d0 UBYTE);    /* character to convert        */
  64. ULONG __asm SDI_isalnum(register __d0 UBYTE);    /* character to convert        */
  65. ULONG __asm SDI_isupper(register __d0 UBYTE);    /* character to convert        */
  66. ULONG __asm SDI_strtoul(register __a1 STRPTR,    /* buffer            */
  67.             register __a0 STRPTR *,    /* UBYTE var for error position    */
  68.             register __d2 UBYTE);     /* base                */
  69. ULONG __asm SDI_strtol(    register __a1 STRPTR,    /* buffer            */
  70.             register __a0 STRPTR *,    /* UBYTE var for error position */
  71.             register __d2 UBYTE);     /* base                */
  72. STRPTR __asm SDI_strncpy(register __a1 STRPTR,    /* string 1            */
  73.             register __a0 STRPTR,    /* string 2            */
  74.             register __d1 ULONG);    /* highest copy number        */
  75. void __asm SDI_memset(    register __a1 APTR,    /* buffer            */
  76.             register __d0 UBYTE,    /* fill character        */
  77.             register __d1 ULONG);    /* number of bytes        */
  78. STRPTR __asm SDI_strchr(register __a1 STRPTR,    /* buffer            */
  79.             register __d0 UBYTE);    /* character to scan for    */
  80. void __asm SDI_vsprintf(register __a3 STRPTR,    /* buffer            */
  81.             register __a0 STRPTR,    /* formatstring            */
  82.             register __a1 APTR);    /* data                */
  83. void SDI_sprintf(STRPTR, STRPTR, ...);        /* buffer, formatstring, data    */
  84. void SDI_printf(STRPTR, ...);            /* formatstring, data        */
  85.  
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89.  
  90. #define SDI_stricmp(a,b)    SDI_strnicmp(a,b,~0)
  91. #define SDI_strcmp(a,b)        SDI_strncmp(a,b,~0)
  92. #define SDI_strcpy(a,b)        SDI_strncpy(a,b,~0)
  93.  
  94. /* Set SDI_TO_ANSI if you want to use normal ANSI names. Do not include
  95. the ANSI files stdio.h / stdlib.h ... , because this may result in an error */
  96.  
  97. #ifdef SDI_TO_ANSI
  98.   #define strnicmp    SDI_strnicmp
  99.   #define strncmp    SDI_strncmp
  100.   #define stricmp    SDI_stricmp
  101.   #define strcmp    SDI_strcmp
  102.   #define tolower    SDI_tolower
  103.   #define toupper    SDI_toupper
  104.   #define strlen    SDI_strlen
  105.   #define isprint    SDI_isprint
  106.   #define isdigit    SDI_isdigit
  107.   #define isxdigit    SDI_isxdigit
  108.   #define isalnum    SDI_isalnum
  109.   #define strtoul    SDI_strtoul
  110.   #define strtol    SDI_strtol
  111.   #define strncpy    SDI_strncpy
  112.   #define strcpy    SDI_strcpy
  113.   #define strchr    SDI_strchr
  114.   #define memset    SDI_memset
  115.   #define sprintf    SDI_sprintf
  116.   #define printf    SDI_printf
  117.   #define vsprintf    SDI_vsprintf
  118.  
  119.   extern void exit(int);
  120. #endif
  121.  
  122. /* Use the following with care, as they may collide with ANSI-C Standard
  123.    a lot more, than the above ones. The FILE * parameter of the functions
  124.    is converted into a filehandle of dos.library. Do not mix normal ANSI-C
  125.    and these functions! */
  126.  
  127. /* These defines are in experimental state !!! */
  128.  
  129. #ifdef AMIGA_TO_ANSI
  130.   #define memcpy(a,b,c)        CopyMem(b,a,c)
  131.   #define remove(a)        !DeleteFile(a)
  132.   #define rename(a,b)        !Rename(a,b)
  133.   #define putchar(a)        FPutC(Output(),a)
  134.   #define putc(a, b)        FPutC((ULONG) b, a)
  135.   #define getchar()        FGetC(Input())
  136.   #define getc(a)        FGetC((ULONG) a)
  137.   #define ungetc(a,b)        UnGetC((ULONG) b,a)
  138.   #define vprintf(a,b)        VPrintf(a,b)
  139.   #define vfprintf(a,b,c)    VFPrintf((ULONG) a, b, c)
  140.   #define fclose(a)        Close(a)
  141. #endif
  142.  
  143. #endif /* SDI_ASM_STD_PROTOS_H */
  144.